<template>
    <tr>
    <td>
      <input type="checkbox" v-model="obj.checked" />
    </td>
    <td>{{obj.name}}</td>
    <td>{{obj.price}}</td>
    <td>
      <button @click="sub" :disabled="obj.num === 0">-</button>
      <span>{{obj.num}}</span>
      <button @click="add">+</button>
    </td>
    <td>{{obj.price * obj.num}}元</td>
    <td>
      <button @click="delFn">删除</button>
    </td>
  </tr>
</template>
 
<script>
export default {
  props: ["obj", "index"],
  methods: {
    add(){
      this.obj.num++
    },
    sub(){
      this.obj.num--
    },
    delFn(){
      this.$emit('sub', this.index)
    }
  }
}
</script>